﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace iHub
{
    public partial class cashadvances : Form
    {
        public cashadvances()
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(Date_Closing);
        }

        private void Date_Closing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                main.form.Enabled = true;
            }
        }

        private void setcash_Click(object sender, EventArgs e)
        {
            int casha = 0;
            if (advances.Text != "")
            {
                casha = Convert.ToInt32(advances.Text);

                if (casha > 0)
                {
                    main.form.Enabled = true;
                    main.form.paysetAdvances(casha);
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("Value must be greater than 0", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
            else
            {
                MessageBox.Show("Please enter a valid amount", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
    }
}
